feat(tools): add Safety plan generator as a Tools-page tool (not a mode)#1068
Conversation
Promote the patient safety-plan generator from a /mockups prototype to a production Tools-page tool, reachable at /safety-plan without registering it as an app mode. - Rename patient-safety-plan-mockup.tsx -> patient-safety-plan.tsx and export PatientSafetyPlan; tokenise the two 44px tap classes (min-h-tap, size-tap) and add aria-hidden to a decorative icon now that the file is production (no longer mockup-exempt from the design-system/lint gates). - Add the /safety-plan route (src/app/safety-plan/page.tsx). - Retire the redundant /mockups/patient-safety-plan route and its mockups-layout-client special-case. - Add a "safety-plan" Tools catalog tile (href /safety-plan, care area, safety-first), its launcher icon, and a reachability fixture. - Regenerate docs/site-map.md and index the route in docs/codebase-index.md. app-modes.ts is intentionally untouched: this is a tool, not a mode. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Jurbrad9ZeWo45EQpxBzR
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds the Safety plan tool to catalog and directory data, exposes it at ChangesSafety plan tool
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant ToolDirectory
participant SafetyPlanPage
participant PatientSafetyPlan
participant PrintStyles
ToolDirectory->>SafetyPlanPage: provides /safety-plan route
SafetyPlanPage->>PatientSafetyPlan: renders the safety plan tool
PatientSafetyPlan->>PrintStyles: supplies printable-copy markers
PrintStyles->>PatientSafetyPlan: formats the patient-copy document
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
…an tile Adding the safety-plan Tools fixture grows the shared mockup tool set from 7 to 8 (Safety plan is a care-area = "Clinical" tool), so the task-directory mockup's derived counts shift: total 7 -> 8 and the Clinical chip 4 -> 5; the Admin chip stays 3. Update the Playwright expectations to match. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Jurbrad9ZeWo45EQpxBzR
There was a problem hiding this comment.
💡 Codex Review
Database/src/components/patient-safety-plan.tsx
Lines 477 to 478 in cf2047b
When a desktop user clicks “Print / PDF”, this calls window.print() for the whole page with no safety-plan-specific print mode; the existing global print CSS hides headers/nav/buttons but does not hide #spg-panel-build, and it also hides the preview document header because it is a <header>. The advertised patient-copy export therefore includes builder/editor content and loses the plan title/name/date area instead of printing only the handover copy; add a print-only sheet or scoped no-print/print classes before exposing this as a clinical tool.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/patient-safety-plan.tsx`:
- Around line 40-49: Update the clearAll handler to reset patient context
fields, including patient and planDate, along with the existing plan content
fields. Ensure the cleared state is used consistently by the preview and copied
output, while preserving the current Clear all behavior for the remaining form
data.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 691c4469-0edb-4f35-bb76-6033cce4cf7f
📒 Files selected for processing (11)
docs/codebase-index.mddocs/site-map.mdscripts/generate-site-map.tssrc/app/mockups/mockups-layout-client.tsxsrc/app/mockups/patient-safety-plan/page.tsxsrc/app/safety-plan/page.tsxsrc/components/applications-launcher-page.tsxsrc/components/patient-safety-plan.tsxsrc/components/tools-page-mockups/tool-fixtures.tssrc/lib/tools-catalog.tstests/ui-tools-task-directory.spec.ts
💤 Files with no reviewable changes (1)
- src/app/mockups/patient-safety-plan/page.tsx
…, clear-all Resolves the review findings on the promoted /safety-plan tool: - Start empty (Codex P2): a fresh plan boots blank instead of seeding sample content, so placeholder names and non-working example crisis numbers can no longer reach a Finalise/Copy/Print handover. A new "Load example" button restores the Stanley-Brown sample on demand for demos/training, keeping the seed data as an opt-in fixture rather than a default. - Print isolation (Codex P2): "Print / PDF" (and Cmd+P) now export the patient copy only. Builder/editor chrome is marked data-print-hide, the patient-copy pane is data-safety-plan-copy, and a scoped @media print block restores the document header that the global `header { display:none }` rule would drop. - main-content landmark (Codex P2): the component root is now <main id="main-content" tabIndex={-1}>, so the layout's skip link has a live target and assistive tech gets the expected main landmark on /safety-plan. - Clear all (CodeRabbit): also resets patient name and date so stale patient identifiers can't carry into the next plan. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Jurbrad9ZeWo45EQpxBzR
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/patient-safety-plan.tsx`:
- Around line 493-497: Update loadExample to confirm before replacing a
non-empty plan, aborting without changes when the user declines. When confirmed
or no plan content exists, replace the entries and reasons with the seed data,
reset finalised, and also clear the patient and planDate context so sample
content cannot retain real patient identity or date.
🪄 Autofix (Beta)
❌ Autofix failed (check again to retry)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 5642164f-c3c4-467e-ad51-fd32e1091c2f
📒 Files selected for processing (2)
src/app/globals.csssrc/components/patient-safety-plan.tsx
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c97448eab1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ntity Codex (P2) and CodeRabbit (Major) flagged that the example loader could bridge sample content into patient output. loadExample now: - confirms before replacing a non-empty in-progress plan (prevents accidental loss of a clinician's work), and - clears patient name and date, so the Priya/Jordan/Biscuit example content can never sit under a real patient's identity in the preview/print copy. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017Jurbrad9ZeWo45EQpxBzR
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found. |
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f0a125fb5a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 69cea27492
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
/mockupsprototype to a production Tools-page tool, reachable at/safety-plan— without registering it as an app mode (src/lib/app-modes.tsis intentionally untouched: it gets no sidebar/MODE-dropdown/mode-home entry).patient-safety-plan-mockup.tsx→patient-safety-plan.tsx(exportPatientSafetyPlan). Now that it is a production file (no longer-mockup-exempt from the design-system/lint gates), tokenises the two 44px tap classes (min-h-tap,size-tap) and addsaria-hiddento a decorative icon.src/app/safety-plan/page.tsx(thin server component rendering<PatientSafetyPlan />)./mockups/patient-safety-planroute and itsmockups-layout-clientspecial-case.safety-planTools catalog tile (href: /safety-plan,carearea,safety-first), its launcher icon (ClipboardList), and a reachability fixture so the route passesroute-reachability+site-mapgates. Distinct from the existingrisk-safetytool, which is a safety-check query, not a plan builder.docs/site-map.mdand indexes the route indocs/codebase-index.md.RAG impact: no retrieval behaviour change — self-contained UI tool + Tools tile; no
src/lib/rag/**, clinical-search, retrieval, ranking, or eval surfaces touched.Verification
npm run verify:cheap— green (lint, typecheck,route-reachability,tools-catalog,site-map, design-system contract,docs:check-index,sitemap:check, knip).npm run verify:pr-local— unit suite 3164 passed. The sole failure,tests/pdf-extraction-budget.test.ts("terminates the Python child tree when the total deadline expires"), is pre-existing and environment-limited: it fails identically on the base tree with this branch's changes stashed, and touches no code in this diff. The gate's conditional production build sits behind that pre-existing failure.verify:ui) was not run locally; the change adds a self-contained page plus a literal Tools tile link, both covered by theroute-reachabilityandsite-mapunit tests. Recommendverify:uiin review/CI.npm run verify:release: not applicable (no release/handoff claim).eval:retrieval:quality/eval:rag/eval:quality: not applicable — no retrieval, ranking, selection, chunking, or answer-generation behaviour changed.Risk and rollout
/safety-planpage and a Tools launcher tile. No auth, data, Supabase, ingestion, retrieval, or provider paths touched;app-modes.tsunchanged./mockups/patient-safety-planprototype.Clinical Governance Preflight
The tool produces clinical output (a safety-plan document), so completing this section:
Clinical KB Database(sjrfecxgysukkwxsowpy) — untouched.Notes
Generated by Claude Code
Summary by CodeRabbit